package com.demo.netty.repository;

import com.demo.netty.entity.MessageEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface MessageRepository extends JpaRepository<MessageEntity, Long> {
    
    /**
     * 根据接收者ID查找离线消息
     */
    List<MessageEntity> findByReceiverAndIsOfflineMessageTrue(String receiver);
    
    /**
     * 根据发送者ID查找消息
     */
    List<MessageEntity> findBySender(String sender);
    
    /**
     * 根据接收者ID查找消息
     */
    List<MessageEntity> findByReceiver(String receiver);
}